<template>
    <div
        class="cardFeeReduction"
        v-loading="pageLoading"
        element-loading-background="rgba(255, 255, 255, 0.7)"
    >
        <el-card class="box-card">
            <div slot="headerss" class="clearfix text_fl">
                <span>功能设置-->年费减免</span>
                <el-button class="btn_close" type="text" @click="handleClose">关闭</el-button>
            </div>
            <div>
                <div v-show="step1Page">
                    <el-form ref="formData" :model="formData" :rules="rules" label-width="250px">
                        <el-row>
                            <div class="text_center width30">
                                <el-form-item label="卡号：" class="text_fl">
                                    <span class="el-form-item-span">{{formData.CARDNO}}</span>
                                </el-form-item>
                            </div>
                            <div class="text_center width30">
                                <el-form-item label="卡种：" class="text_fl">
                                    <span class="el-form-item-span">{{this.PRODUCT_value}}</span>
                                </el-form-item>
                            </div>
                        </el-row>
                        <el-row>
                            <div class="text_center width30">
                                <el-form-item label="卡片状态：" class="text_fl">
                                    <span
                                        class="el-form-item-span"
                                    >{{this.cardStat_str | filterCardstat}}</span>
                                </el-form-item>
                            </div>
                            <div class="text_center width30">
                                <el-form-item label="是否在年费减免执行期内：" class="text_fl">
                                    <span class="el-form-item-span">{{formData.CYNBR }}日</span>
                                </el-form-item>
                            </div>
                        </el-row>
                        <el-row>
                            <el-col :span="18" :offset="4">
                                <div class="text_center width30">
                                    <el-form-item label="下次年费收取时间：" class="text_fl">
                                        <span class="el-form-item-span">暂无查询</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <div class="text_center">
                            <el-button type="primary" size="small" @click="fisrtHandle">初审</el-button>
                        </div>
                    </el-form>

                    <div class="content table_eltabs" v-show="noReductionReasonFlag">
                        <h1>不能减免原因：</h1>
                        <el-table
                            :data="noReductionList"
                            style="width: 100%"
                            border
                            height="200px"
                            class="table_head heard-bg setbottomborder"
                            :stripe="true"
                        >
                            <el-table-column label="编号" min-width="20">
                                <template slot-scope="scope">{{ scope.row.id }}</template>
                            </el-table-column>
                            <el-table-column label="类型" min-width="80">
                                <template slot-scope="scope">{{ scope.row.type }}</template>
                            </el-table-column>
                            <el-table-column label="详情" min-width="180">
                                <template slot-scope="scope">{{ scope.row.desc }}</template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
                <div v-show="step2Page">
                    <h1>调整：</h1>
                    <el-divider></el-divider>
                    <el-form ref="formData" :model="formData" :rules="rules" label-width="250px">
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="账单日期：" class="text_fl">
                                        <span class="el-form-item-span">{{formData.CYNBR }}日</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <!-- <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="开始账期：" class="text_fl">
                                        <el-input
                                            placeholder="请输入开始账期"
                                            maxlength="6"
                                            v-model="formData.startAcctDate"
                                        ></el-input>
                                        <span style="color:red">(YYYYMM)</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="结束账期：" class="text_fl">
                                        <el-input
                                            placeholder="请输入结束账期"
                                            maxlength="6"
                                            v-model="formData.endAcctDate"
                                        ></el-input>
                                        <span style="color:red">(YYYYMM)</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>-->
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="本期账单未还金额：" class="text_fl">
                                        <span class="el-form-item-span">{{this.curBillNotRepayAmt }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="最后还款日：" class="text_fl">
                                        <span class="el-form-item-span">{{this.finalRepayDate }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="执行日期：" class="text_fl">
                                        <span class="el-form-item-span">{{formData.executionDate }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="减免条件：" class="text_fl">
                                        <span>{{Object.keys(cardFeeRule).length==0 ?'暂无':cardFeeRule.cardfeeReductionCondition}}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <div class="text_center">
                            <el-button
                                type="primary"
                                size="small"
                                @click="handerCardFeeReduction"
                            >调整</el-button>
                        </div>
                    </el-form>
                    <!-- <h3>必讲话术：</h3>
                    <div class="content table_eltabs">
                        <el-table
                            :data="speechCraftList"
                            style="width: 100%"
                            border
                            height="200px"
                            class="table_head heard-bg setbottomborder"
                            :stripe="true"
                        >
                            <el-table-column label="编号" min-width="20">
                                <template slot-scope="scope">{{ scope.row.sortNum }}</template>
                            </el-table-column>
                            <el-table-column label="内容" min-width="80">
                                <template slot-scope="scope">{{ scope.row.content }}</template>
                            </el-table-column>
                        </el-table>
                    </div>-->
                </div>
                <div v-show="step3Page">
                    <h1>执行结果：</h1>
                    <el-divider></el-divider>
                    <h3>年费减免调整执行成功！</h3>
                    <el-form ref="formData" :model="formData" :rules="rules" label-width="250px">
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="执行日期：" class="text_fl">
                                        <span class="el-form-item-span">{{formData.executionDate }}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <div class="text_center width30">
                                    <el-form-item label="减免条件：" class="text_fl">
                                        <span>{{Object.keys(cardFeeRule).length==0 ?'暂无':cardFeeRule.cardfeeReductionCondition}}</span>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <div class="text_center">
                            <el-button type="primary" size="small" @click="sendSMSHandle">发送短信</el-button>
                        </div>
                    </el-form>
                </div>
                <!-- 以下弹窗 -->
                <el-dialog
                    v-drag
                    title="年费减免"
                    :visible.sync="centerDialogVisible"
                    width="500px"
                    :append-to-body="true"
                    top="30vh"
                    :close-on-click-modal="false"
                    center
                >
                    <p>
                        卡号：
                        <span>{{this.formData.CARDNO}}</span>
                    </p>
                    <p>
                        卡种:
                        <span>{{this.PRODUCT_value}}</span>
                    </p>
                    <p style="text-align:center;padding-left:0px;">
                        <span style="color:#3a8ee6; ">您确认要年费减免吗？</span>
                    </p>
                    <span slot="footer" class="dialog-footer">
                        <el-button
                            size="small"
                            icon="el-icon-circle-close"
                            @click="centerDialogVisible = false"
                        >取 消</el-button>
                        <el-button
                            type="primary"
                            size="small"
                            @click="setsubmitForm"
                            icon="el-icon-circle-check"
                        >确定</el-button>
                    </span>
                </el-dialog>
                <el-dialog
                    v-drag
                    title="年费减免"
                    :visible.sync="DialogVisibleSuccess"
                    width="500px"
                    :append-to-body="true"
                    top="30vh"
                    :close-on-click-modal="false"
                    center
                >
                    <p>
                        卡号：
                        <span>{{this.formData.CARDNO}}</span>
                    </p>
                    <p style="text-align:center;padding-left:0px;">
                        <span style="color:#3a8ee6; ">年费减免成功！</span>
                    </p>
                    <span slot="footer" class="dialog-footer">
                        <!-- <el-button size="small" @click="centerDialogVisible = false">取 消</el-button> -->
                        <el-button
                            type="primary"
                            size="small"
                            @click="DialogVisibleSuccess = false"
                            icon="el-icon-circle-check"
                        >确定</el-button>
                    </span>
                </el-dialog>
            </div>
        </el-card>
    </div>
</template>
<script>
import { mapGetters } from 'vuex';
import moment from 'moment';
import {
    closePage,
    trimString,
    getDictSelectList,
    itoStr,
    getDictMappingValue,
} from '@/utils/Common';
import { get_3xxx } from '@/apis/getAPIClass';

export default {
    name: 'CardFeeReduction',
    data() {
        return {
            formData: {
                CARDNO: '',//卡号
                CYNBR: '',// 账单日
                CHGDY: '',// 上次帐单日修改日期
                CYCLENBRSVal: '',//有效账单日
                CYCLENBRS_option: [],
                CYCLENBRS_option_value: '',
                startAcctDate: '', //开始账期
                endAcctDate: '', //结束账期
                executionDate: '', //执行日期
                currentDateStr: '', //获取服务器当前日期 eg.20210518

            },
            centerDialogVisible: false,
            DialogVisibleSuccess: false,
            pageLoading: false,
            bilDayQuery_3018: '',//有效账单日查询接口 返回数据
            PRODUCT_value: '',//卡产品
            cardserver_3014: '',//信用卡服务方式综合查询
            CardFeeReduction_4050: '',
            markedWords: '',//提示语
            rules: {
                CYCLENBRSVal: [{ required: true, message: '调整的新账单日期不能为空', trigger: 'blur' }],
            },
            speechCraftList: [], //话术列表
            cardtypeNo: '', //卡类型编号
            cardFeeRule: {}, //卡费规则描述
            step1Page: true,//1-初审
            step2Page: false,//2-调整
            step3Page: false,//3-执行结果
            cardStat: '', //卡状态编码
            cardStat_str: '', //卡状态显示
            tran3053Form: {}, //3053查询结果体
            curBillNotRepayAmt: '', //本期账单未还金额
            finalRepayDate: '', //最后还款日
            noReductionList: [], //不可减免原因列表
            noReductionReasonFlag: false, //不可减免原因列表显示/不显示
        }
    },
    computed: {
        ...mapGetters([
            'cardInfo_3004',
            'cardAccountInfo_3001',
            'defaultParams',
            'pinFlag',
            'CreditCardService_3014',
        ]),
    },
    filters: {
        filterDateYYYYMMDD: (value) => {
            value = (`${value}`).trim();
            if (value === '00000000') return value;
            if (value) {
                return moment(value, 'YYYYMMDD').format('YYYY-MM-DD');
            }
            return '';
        },
        filterCYCLENBRS_option: (value) => {
            let optionVal = '';
            value.forEach((item) => {
                optionVal = optionVal + item + '日 '
            })
            return optionVal
        },
        filterCardstat: (value) => {
            value = (`${value}`).trim();
            if (value === '') return '正常';
            return value;
        },

    },
    async mounted() {

        console.info("========================cardInfo_3004", this.cardInfo_3004);
        this.formData.CARDNO = this.cardInfo_3004.CARDNO || this.cardInfo_3004.CARDNBR;
        this.formData.pinFlag = this.pinFlag; // 0-不检查密码 1-检查卡片级查询密码 2-检查取款密码 3-检查客户级查询密码
        this.formData.KEYTYPE = this.cardInfo_3004.KEYTYPE;// 证件类型
        this.formData.CUSTID = this.cardInfo_3004.CUSTID;// 证件类型
        this.cardtypeNo = this.cardInfo_3004.PRODUCT;// 产品编号
        this.cardStat = this.cardInfo_3004.CARDSTAT.trim();// 卡状态编码
        //result_3053
        console.info('=================this.cardStat:', this.cardStat);
        this.cardStat_str = await getDictMappingValue('CLOCD', this.cardStat, this);// 卡状态显示
        console.info('=================this.cardStat_str:', this.cardStat_str);
        this.getDictInfovalue();
        await this.updatecurrentDateStr();
        this.setCardServerQuery();//3014
        this.get3053Query();//3053  curBillNotRepayAmt-本期账单未还金额;finalRepayDate-最后还款日

        //这里开始判断是否可以进行账单日修改 
        // this.judgeViwe();

        this.getInit();

        this.loadSpeechList('cardfee_reduction');
    },
    methods: {
        // 初始化页面数据
        async getInit() {
            // this.formData.CATEGORY = this.cardInfo_3004.CATEGORY
            // 卡产品
            this.formData.CATEGORY_filter = await getDictMappingValue('CATE', this.cardInfo_3004.CATEGORY, this);
            console.log('this.cardInfo_3004', this.cardInfo_3004);
            await this.getCardValidBillDayQuery();
        },
        // 请求数据字典里的字段
        async getDictInfovalue() {
            // this.isDSPCHCDOption = await getDictSelectList('DSPCHCD', this);
            // this.isCARDTOOption = await getDictSelectList('账单地址类型', this);
            this.isREPLACEFEEOption = await getDictSelectList('REPFEE', this);
            // this.isCOURIERFEEOption = await getDictSelectList('COURFEE', this);
            this.PRODUCT_value = await getDictMappingValue('PRODUCT', this.cardInfo_3004.PRODUCT, this);
            // this.CATEGORY_filter = await getDictMappingValue('CATE', this.cardInfo_3004.CATEGORY, this);
            // this.getExecuteFun();    
            // this.disPoseName(this.cardInfo_3004.EMBNAME, this.cardInfo_3004.EMBOSSSUL, this.cardInfo_3004.EMBOSSSUR);

            // 根据卡片的类型编号，查询卡片的卡费用
            // this.cardtypeNo = this.cardInfo_3004.PRODUCT;// 产品编号
            // this.cardInfo_3004.CATEGORY;// 账户类别
            var cardfeeQueryParam = {
                // 'cardTypeNo': this.cardtypeNo, 
                'cardTypeNo': this.cardInfo_3004.PRODUCT,
            };

            console.info("========================cardfeeQueryParam" + JSON.stringify(cardfeeQueryParam));
            this.$post.queryServiceClass.getCardfeeByCardTypeNo(cardfeeQueryParam).then((res) => {
                if (res.status === 200) { // http通讯成功
                    if (res.data.status == 0) { // 业务请求成功
                        if (res.data.content) {
                            this.cardFeeRule = res.data.content;
                        }
                    } else {
                        const ErrorMessage = `错误码：${res.data.status} ` + `错误信息：${res.data.msg}`;
                        this.$alert(ErrorMessage, '查询年费减免条件异常:', {
                            customClass: 'error', type: 'error',
                        });
                    }
                }
            });
        },
        loadSpeechList(spType) {
            // 查询加载话术
            var speechQueryParam = {
                'code': spType, //话术类型编号-年费减免
            };
            this.$post.queryServiceClass.speechcraftlistByCode(speechQueryParam).then((res) => {
                if (res.status === 200) { // http通讯成功
                    if (res.data.status == 0) { // 业务请求成功
                        this.speechCraftList = res.data.content;
                        console.log("spType" + spType, "this.speechCraftList", this.speechCraftList);
                    } else {
                        const ErrorMessage = `错误码：${res.data.status} ` + `错误信息：${res.data.msg}`;
                        this.$alert(ErrorMessage, '请求异常:', {
                            customClass: 'error', type: 'error',
                        });
                    }
                }
            });
        },
        // 有效日期 转格式
        formattingCYCLENBRS(value) {
            value = (`${value}`).trim();
            let val = [];
            if (value === '') return ''
            value.split('').forEach((item, index) => {
                if (item === '1') {
                    index = index + 1
                    // index <= 9 ? index = '0' + index : index = '' + index
                    val.push(index)
                }
            })
            return val
        },
        // 是否可以进行账单日修改
        judgeViwe() {
            if (this.cardInfo_3004.MAFLAG !== '1') {
                this.markedWords = '当前卡必须为主卡';
                return;
            }
            // console.log('1111111100000', moment('20200602', 'YYYYMMDD').format('YYYY'));
            if (this.cardserver_3014.body.appBody.CHGDY !== '00000000') {
                let CHGDY_3014 = moment(this.cardserver_3014.body.appBody.CHGDY, 'YYYYMMDD').format('YYYY');
                let CurrentYear = moment(new Date()).format('YYYY');
                // 判断当前年份和3014年份是否相同
                if (CHGDY_3014 * 1 == CurrentYear * 1) {
                    this.markedWords = '本年度（自然年）已修改过账单日期 上次修改日期为 ' + this.cardserver_3014.body.appBody.CHGDY;
                    return;
                }
            }
            if (!this.cardAccountInfo_3001.STMTDTE.trim()) {
                this.markedWords = '未到首次账单日，不可做修改操作!';
                return;
            }
            if (this.cardInfo_3004.CARDSTAT.trim() !== '') {
                this.markedWords = '卡片状态异常';
                return;
            }
        },
        //开始年费减免
        handerCardFeeReduction() {
            this.$refs.formData.validate((valid) => {
                if (valid) {
                    if (this.formData.CYNBR === this.formData.CYCLENBRSVal) {
                        this.$alert('修改的新账单日与原账单日相同', '年费减免提示', {
                            customClass: 'warning', type: 'warning',
                        });
                        return;
                    } else if (this.cardFeeRule.cardfeeReductionCondition == '暂免') { //暂免
                        this.$alert('年费减免条件：暂免，无需申请！', '年费减免提示', {
                            customClass: 'warning', type: 'warning',
                        });
                        return;
                    } else {
                        this.centerDialogVisible = true;// 确认弹窗
                    }
                }
            });


        },

        //  从服务器查询获取当前日期字符串
        async updatecurrentDateStr() {
            await this.$post.queryServiceClass.getCurrentDateString().then((res) => {
                console.log("============getCurrentDateString:", res);
                if (res.status === 200) { // http通讯成功
                    if (res.data.status == 0) { // 业务请求成功
                        this.formData.currentDateStr = res.data.content;
                    } else {
                        const ErrorMessage = `错误码：${res.data.status} ` + `错误信息：${res.data.msg}`;
                        this.$alert(ErrorMessage, '请求异常:', {
                            customClass: 'error', type: 'error',
                        });
                    }
                }
            });

        },

        // 要先获取账号类型  如果切换了账户类型 修改的是当前账户的 账单日的
        setCardServerQuery() {
            console.log("============setCardServerQuery");
            const defaultParams = JSON.parse(JSON.stringify(this.defaultParams));
            defaultParams.body.appHead.tranCode = '3014';// 修改交易号
            defaultParams.body.appBody.CARDNBR = this.formData.CARDNO;//卡号
            defaultParams.body.appBody.PINFLAG = this.pinFlag// 验密
            //
            this.$post.common.transPort(defaultParams).then((res) => {
                if (res.status === 200) { // 请求成功
                    const cardserver = JSON.parse(res.data.jsonRes);
                    if (cardserver.sysHead.rspCd == '000000') { // 交易成功
                        console.log(cardserver, 'cardserver_3014');
                        this.cardserver_3014 = cardserver;
                        // 账单日
                        this.formData.CYNBR = cardserver.body.appBody.CYNBR;

                        // 计算开始、结束账期，执行日期
                        var stmtday = cardserver.body.appBody.CYNBR; //eg.25
                        var currDate = this.formData.currentDateStr; //eg.20210518
                        console.info('============currDate------' + currDate);
                        var cYear = currDate.substr(0, 4);
                        var cMonth = currDate.substr(4, 2);

                        //计算下一月
                        var tmpM = parseInt(cMonth, 10) + 1;

                        var nMonth;
                        if (tmpM < 10) {
                            nMonth = "0".concat(tmpM.toString());
                        } else if (tmpM == 13) {
                            nMonth = "01";
                            cYear = (parseInt(cYear, 10) + 1).toString();
                        } else {
                            nMonth = tmpM.toString();
                        }

                        //计算账单日前一天
                        var tmpD = parseInt(stmtday, 10) - 1;
                        var preDay;
                        if (tmpD < 10) {
                            preDay = "0".concat(tmpD.toString());
                        } else {
                            preDay = tmpD.toString();
                        }

                        this.formData.startAcctDate = currDate.substr(0, 6); //开始账期 eg.202105
                        this.formData.endAcctDate = cYear.concat(nMonth); //结束账期 eg.202106
                        this.formData.executionDate = cYear.concat(nMonth).concat(preDay); //执行日期 eg.20210624
                        console.info('startAcctDate------' + this.formData.startAcctDate);
                        console.info('endAcctDate------' + this.formData.endAcctDate);
                        console.info('executionDate------' + this.formData.executionDate);

                        // 上次帐单日修改日期
                        // this.formData.CHGDY = cardserver.body.appBody.CHGDY;

                        // this.ReissueCardSuccess.CATEGORY_filter = this.CATEGORY_filter;
                        // this.ReissueCardSuccess.CARDNO = this.formData.CARDNO;
                    } else {
                        const ErrorMessage = `错误码：${cardserver.sysHead.rspCd} ` + `错误信息：${cardserver.sysHead.rspMsg}`;
                        this.$alert(ErrorMessage, cardserver.sysHead.busiName, { customClass: 'error', type: 'error' });
                    }
                }
            });
        },
        // 3053-信用卡账单应还款金额查询
        async get3053Query() {
            // 3053 配置请求头
            const appBody_3053 = {
                CARDNBR: this.cardInfo_3004.CARDNO,
                COVERTTY: 0, // 汇率种类
                PINFLAG: this.defaultpinFlag,
            };
            const result_3053 = await get_3xxx('3053', '账单分期查询', appBody_3053, this, false,);
            console.info('=================result_3053', result_3053);
            if (!result_3053) return false;
            this.tran3053Form = result_3053.body.appBody;
            this.curBillNotRepayAmt = this.tran3053Form.OPENAMT; //本期账单未还金额
            this.finalRepayDate = this.tran3053Form.DUEDATE; //最后还款日
        },
        //获取账单日查询
        getCardValidBillDayQuery() {
            const defaultParams = JSON.parse(JSON.stringify(this.defaultParams));
            defaultParams.body.appHead.tranCode = '3018';// 修改交易号
            defaultParams.body.appBody = {
                CARDNBR: this.formData.CARDNO,//卡号
                CHECKFLG: '00000000',// 检查项
                PINFLAG: this.pinFlag,// 验密
            };
            //
            this.$post.common.transPort(defaultParams).then((res) => {
                if (res.status === 200) { // 请求成功
                    const cardBilling = JSON.parse(res.data.jsonRes);
                    if (cardBilling.sysHead.rspCd == '000000') { // 交易成功
                        console.log(cardBilling, 'cardBilling_3018');
                        this.bilDayQuery_3018 = cardBilling;
                        // 有效账单日期
                        this.formData.CYCLENBRS = cardBilling.body.appBody.CYCLENBRS;
                        this.formData.CYCLENBRS_option = this.formattingCYCLENBRS(cardBilling.body.appBody.CYCLENBRS);
                        // this.ReissueCardSuccess.CATEGORY_filter = this.CATEGORY_filter;
                        // this.ReissueCardSuccess.CARDNO = this.formData.CARDNO;
                    } else {
                        const ErrorMessage = `错误码：${cardBilling.sysHead.rspCd} ` + `错误信息：${cardBilling.sysHead.rspMsg}`;
                        this.$alert(ErrorMessage, cardBilling.sysHead.busiName, { customClass: 'error', type: 'error' });
                    }
                }
            });
        },
        // // 发送请求 年费减免 4050 
        setsubmitForm() {
            let params = {
                CARDNBR: this.formData.CARDNO,//卡号
                PINFLAG: this.pinFlag,// 验密，不检查
                OPERATE: '0',// 操作类型：0：输入
                BEGINMTH: this.formData.startAcctDate,//开始账期，操作类型是0时必填
                ENDMTH: this.formData.endAcctDate,// 结束账期，操作类型是0时必填
                ACTDAY: this.formData.executionDate,// 执行日期
                TOTAMT: this.cardFeeRule.totAmt,//累计交易金额，操作类型是0时必填
                TOTCNT: this.cardFeeRule.totCnt,//累计交易次数，操作类型是0时必填
                // 
            }
            const defaultParams = JSON.parse(JSON.stringify(this.defaultParams));
            defaultParams.body.appHead.tranCode = '4050';// 修改交易号
            defaultParams.body.appBody = params;


            this.$post.common.transPort(defaultParams).then((res) => {
                if (res.status === 200) { // 请求成功
                    const transRes = JSON.parse(res.data.jsonRes);
                    console.log(transRes, 'CardFeeReduction_4050');
                    if (transRes.sysHead.rspCd == '000000') { // 交易成功
                        this.CardFeeReduction_4050 = transRes;
                        this.DialogVisibleSuccess = true;
                        // 关闭当前页，展示结果成功页
                        this.step2Page = false;
                        this.step3Page = true;
                    } else {
                        const ErrorMessage = `错误码：${transRes.sysHead.rspCd} ` + `错误信息：${transRes.sysHead.rspMsg}`;
                        this.$alert(ErrorMessage, transRes.sysHead.busiName, { customClass: 'error', type: 'error' });
                    }
                    this.centerDialogVisible = false;
                }
            });
        },

        // 点击关闭
        handleClose() {
            closePage(this.$route, this, 1);
        },

        // 初审
        fisrtHandle() {
            // 3152-查询年费历史调整记录
            // this.transfer3152();

            // 初审校验
            // this.checkNoReductionRules();
            // if (this.noReductionList.length > 0) { //初审不通过
            //     const ErrorMessage = "初审不通过，请查看下方原因";
            //     this.$alert(ErrorMessage, "年费减免初审", { customClass: 'error', type: 'error' });
            //     this.noReductionReasonFlag = true;
            // } else { //通过
            //     // 关闭初审页，打开调整页
            //     this.step1Page = false;
            //     this.step2Page = true;
            // }
            this.step1Page = false;
            this.step2Page = true;
        },

        // 调整
        changeHandle() {
            // 关闭调整页，打开结果页
            this.step2Page = false;
            this.step3Page = true;
        },

        // 发送短信
        sendSMSHandle() {
            alert("敬请期待");
        },

        // // 发送请求 3152-查询年费历史调整记录
        transfer3152() {
            let params = {
                CARDNBR: this.formData.CARDNO,//卡号
                PINFLAG: this.pinFlag,// 验密，不检查
                RTNRESERVED: '',// 保留域
                RTNIND: '',// 翻页标志
                CLEARFLG: '0',// 处理结果
                ACTDAY: '00000000',// 年费调整方案执行日期
                INPTIME: '00000000',// 年费调整方案输入时间
                // 
            }
            const defaultParams = JSON.parse(JSON.stringify(this.defaultParams));
            defaultParams.body.appHead.tranCode = '3152';// 修改交易号
            defaultParams.body.appBody = params;


            this.$post.common.transPort(defaultParams).then((res) => {
                if (res.status === 200) { // 请求成功
                    const transRes = JSON.parse(res.data.jsonRes);
                    console.log(transRes, 'transfer3152Res');
                    if (transRes.sysHead.rspCd == '000000') { // 交易成功


                    } else {
                        const ErrorMessage = `错误码：${transRes.sysHead.rspCd} ` + `错误信息：${transRes.sysHead.rspMsg}`;
                        this.$alert(ErrorMessage, transRes.sysHead.busiName, { customClass: 'error', type: 'error' });
                    }

                }
            });
        },
        // 校验不可减免原因
        checkNoReductionRules() {
            // 参数：jsonRes_3004，jsonRes_3601

            var reasonObj = {};
            var index = 0;

            // 卡状态异常不可减免
            if (this.cardStat != "") {
                index = index + 1;
                reasonObj.id = index;
                reasonObj.type = "卡状态不正常";
                reasonObj.desc = "卡号-" + this.formData.CARDNO + "，卡状态-" + this.cardStat + this.cardStat_str;
                this.noReductionList.push(reasonObj);
            }

            // 不可减免账户（41-汽车卡66-惠享金卡91-南京徽易贷惠享金）【3004产品编号】
            // 测试用：51-安师大联名卡
            var product = this.cardInfo_3004.PRODUCT + "";
            var productStr = "";
            if (product == "41") {
                productStr = "41汽车卡";
            } else if (product == "66") {
                productStr = "66惠享金卡";
            } else if (product == "91") {
                productStr = "91南京徽易贷惠享金";
            } else if (product == "51") {
                productStr = "51安师大联名卡";
            }
            if (productStr != "") {
                index = index + 1;
                reasonObj.id = index;
                reasonObj.type = "卡产品类型不支持减免";
                reasonObj.desc = "产品编号-" + productStr;
                this.noReductionList.push(reasonObj);
            }

        },
    }
}
</script>
<style lang="scss">
.cardFeeReduction {
    .el-card__header {
        padding: 8px !important;
    }
    .el-form-item__content {
        text-align: left;
        .el-select {
            width: 250px;
        }
    }
    .el-card {
        border-bottom: none;
    }
}
</style>
<style lang="scss" scope>
</style>